
object Inheritance {
   def main() : Unit = {
      println((new Test()).test());
   }
}

class Test{
   def test() : Int = {
      var cat : Animal;
      var dog : Animal;

      cat = new Cat();
      dog = new Dog();
      
      if(!(cat.setName("Garfield") == "Garfield"))
		  println("bob");
      if(dog.setName("Odie") == "Odie")
		  println("the sponge");

      println(dog.print());
      println(cat.print());
      return 0;
   }
}

class Animal{
   var name : String;

   def setName(n : String) : String = {
      name = n;
      return name;
   }

   def print() : String = {
      return (name + " says : " + this.makeNoise());
   }

   def makeNoise() : String = {
      return "noise";
   }
}

class Cat extends Animal{
   def makeNoise() : String = {  	
      return  			    "meowww"    
		  ;
   }
}

class Dog extends Animal{
   def makeNoise() : String = {
      return "baarrk";
   }
}
